var e = require("config.js").config,
  n = require("utils/sha1hmac.js"),
  r = require("utils/xxtea.js"),
  t = require("utils/base64.js").base64Encode,
  i = require("uuid-manager.js"),
  a = require("key-manager.js").KeyManager.getInstance(),
  s = wx.getAccountInfoSync(),
  o = [s.miniProgram.appId, s.plugin.version].join(","),
  u = wx.getSystemInfoSync(),
  g = u.platform + "," + u.model + "," + u.system;
module.exports = {
  sign: function (s) {
    var u,
      c,
      m = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : "",
      l = s + m,
      y = a.getKeyInfo(),
      d = y.clientKey ? y.clientKey : "turingmm";
    y ? ((u = y.ver), (c = 0)) : ((u = 0), (c = -1));
    var f = n.hex_hmac_sha1(d, l),
      h = [
        c,
        f,
        d,
        u,
        e.signVersion,
        "",
        i.uuid,
        a.getChannelId(),
        e.platform,
        Date.now(),
        l.length,
        e.sdkVer,
        g,
        o,
      ].join("_"),
      p = r.encrypt(r.toBytes(h), e.xxteaKey),
      j = t(String.fromCharCode.apply(String, p));
    return j;
  },
};
